// import api from '../../api/login.js'
// 定义用于保存状态的对象
const state = {
    user: {}
}
// getters 获取存储的对象信息
const getters = {
    userInfo: state => state.user
}
// actions 异步动作行为
const actions = {
    login ({commit, state}, param) {
        return api.login(param).then(res => {
            router.replace('/home')
            // 登录跳转到指定页
        })
    },
    getUserInfo ({commit, state}) {
        return api.getUserInfo().then(res => {
            commit('setUser', res.data)
        })
    }
}
// mutations 修改sotre状态
const mutations = {
    setUser (state, userInfo) {
        state.user = userInfo
    }
}
export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}
